package com.mju.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mju.pojo.Favorites;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface FavoritesDao extends BaseMapper<Favorites> {
    //根据uid和收藏商品状态查询收藏的商品信息
    @Select("select * from t_favorites where uid = #{uid} and status = #{status}")
    List<Favorites> queryFavoritesByUidAndStatus(Integer uid, Integer status);

    //根据收藏商品pid和用户uid取消对应商品收藏
    @Update("update t_favorites set status = #{status} where fid = #{fid} and uid = #{uid}")
    Integer updateFavoritesStatus(@Param("status") Integer status,
                                  @Param("fid") Integer fid,
                                  @Param("uid") Integer uid);
}
